<include file='Common:header' />
<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">
	<!-- #section:basics/sidebar -->
	<include file='Common:left' />
	<!-- /section:basics/sidebar -->
	<div class="main-content">
		<div class="main-content-inner">
			<div class="page-content">
				<!--主题-->
				<div class="page-header">
					<h1>您当前操作<small><i class="ace-icon fa fa-angle-double-right"></i>修改网页</small></h1>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<form class="form-horizontal ajaxForm2" name="form0" method="post" action="{:U('news_runedit')}"  enctype="multipart/form-data">
							<input type="hidden" name="n_id" id="n_id" value="{$news_list.n_id}" />
							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 网页名称：  </label>
								<div class="col-sm-10">
									<input type="text" name="news_title" id="news_title"  value="{$news_list.news_title}"   class="col-xs-10 col-sm-6" required/>
									<input type="text" name="news_titleshort" id="news_titleshort"  value="{$news_list.news_titleshort}" placeholder="简短标题，建议6~12字数" class="col-xs-10 col-sm-4" style="margin-left:10px;" />
                                            <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle" id="resone"></span>
											</span>
								</div>
							</div>
							<div class="space-4"></div>
							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 分享简介： </label>
								<div class="col-sm-10">
									<input type="text" name="news_scontent" id="news_scontent" class="col-xs-10 col-sm-10"  maxlength="100" value="{$news_list.news_scontent}"  placeholder="输入网页简介"  />
									<label class="input_last">已限制在100个字以内</label>
								</div>
							</div>
							<div class="space-4"></div>
							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 分享图片： </label>
								<div class="col-sm-10">
									<input type="hidden" name="checkpic" id="checkpic" value="{$news_list.news_img}" />
									<input type="hidden" name="oldcheckpic" id="oldcheckpic" value="{$news_list.news_img}" />
									<a href="javascript:;" class="file" title="点击选择所要上传的图片">
										<input type="file" name="pic_one[]" id="file0" multiple="multiple"/>
										选择上传文件
									</a>
									<span class="lbl">&nbsp;&nbsp;<img src="<if condition="$news_list.news_img neq ''">__ROOT__{$news_list.news_img}<else/>__PUBLIC__/img/no_img.jpg</if>" width="100" height="70" id="img0" ></span>&nbsp;&nbsp;<a href="javascript:;" onclick="return backpic('<if condition="$news_list.news_img eq ''">__PUBLIC__/img/no_img.jpg<else/>{$news_list.news_img}</if>');" title="还原修改前的图片" class="file">
									撤销修改
									</a>
											<span class="lbl">&nbsp;&nbsp;上传前先用PS处理成等比例图片后上传，默认比例400*300像素<br /></span>
								</div>
							</div>
							<div class="space-4"></div>
							<div class="form-group">
								<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 商品选项： </label>
								<div class="col-sm-10">
									<div class="table-responsive">
										<table class="table table-striped table-bordered table-hover">
								            <thead>
								              <tr>
								                <th class="col-sm-2"  align="center">选项名称</th>
								                <th class="col-sm-8" >选项数据&nbsp;(注：多选项数据中间用 | 隔开，需加亮字用{:htmlspecialchars("<em></em>")}包裹)，如{:htmlspecialchars("<em>156</em>")}</th>
								               	<th class="col-sm-2" >操作</th>
								              </tr>
								            </thead>
								            <tbody id="list_data_tbody">
								            	<volist name="attr_list" id="cd">
								            	    <tr class="list_tr" rel="{$i-1}">
								            	    <td class="col-sm-2" ><input type="text"  value="{$cd.title}" class="form-control" name="attr_title[{$cd.sort}]" ></td>     
											        <td class="col-sm-8" ><input type="text" value="{$cd.extra}" class="form-control" name="extra[{$cd.sort}]"></td>
											        <td class="col-sm-2"> 
											        <input type="hidden" value="{$cd.id}" name="attr_id[{$i-1}]">
										                <input type="hidden" value="{$cd.value}" name="value[{$i-1}]" class="value">
										                <input type="hidden" value="{$cd.remark}" name="remark[{$i-1}]" class="remark">
											        <a href="javascript:void(0);" onclick="move_up(this)" class="move_up">↑</a>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onclick="move_down(this)" class="move_down">向下</a>&nbsp;&nbsp;&nbsp;
											        <a href="javascript:void(0);" onclick="remove_tr(this)">删除</a>
											        </td>	
								            	    	
								            	    	
								            	    	
								            	</volist>
								                <tr class="more_tr">
								                	<td colspan="5"><a href="javascript:add_tr()">+增加新字段</a></td>
								              	</tr>
								            </tbody>
								          </table>
								        </div>
								</div>
								
							</div>
							<div class="space-4"></div>
					

						<div class="form-group">
							<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 网页主内容 </label>
							<div class="col-sm-10">
								<script src="__PUBLIC__/ueditor/ueditor.config.js" type="text/javascript"></script>
								<script src="__PUBLIC__/ueditor/ueditor.all.js" type="text/javascript"></script>
								<textarea name="news_content" rows="100%" style="width:100%;"  id="myEditor">{$news_list.news_content}</textarea>
								<script type="text/javascript">
									var editor = new UE.ui.Editor();
									editor.render("myEditor");
								</script>
							</div>
						</div>
						<div class="space-4"></div>

						<div class="clearfix form-actions">
							<div class="col-md-offset-3 col-md-9">
								<button class="btn btn-info" type="submit">
									<i class="ace-icon fa fa-check bigger-110"></i>
									保存
								</button>
	
								&nbsp; &nbsp; &nbsp;
								<button class="btn" type="reset">
									<i class="ace-icon fa fa-undo bigger-110"></i>
									重置
								</button>
							</div>
						</div>
					</form>
				</div>
			</div>
			<!-- <div class="hr hr-24"></div> -->
			
			{/*动态表格数据，js要用的*/ }
			<include file='Common:table' />
			<include file='Common:header_nav' />

		</div><!-- /.page-content -->
	</div>
</div><!-- /.main-content -->

<include file='Common:footer' />

</div><!-- /.main-container -->
<script src="__PUBLIC__/ppy/js/fileinput.js" type="text/javascript"></script>
<script src="__PUBLIC__/ppy/js/fileinput_locale_zh.js" type="text/javascript"></script>
<script>
	$(document).ready(function(){
		$("#news_pic_list").click(function(){
			$("#pic_list").hide();
		});
		$("#news_pic_qqlist").click(function(){
			$("#pic_list").show();
		});

		if(!$("#news_flag_vaj").attr("checked")){
		$("#pptaddress").hide();
		}
		$("#news_flag_vaj").click(function(){
			$("#pptaddress").toggle(400);
		});
		
		if(!$("#news_flag_vacp").attr("checked")){
		$("#cpprice").hide();
		}
		$("#news_flag_vacp").click(function(){
			$("#cpprice").toggle(400);
		});
	});
	
	
		//增加字段
	var tr_sort_id = 0;
	function add_tr(){
		var list_count = 0;
		$('.list_tr').each(function() {
			list_count += 1;
			var sort_id = $(this).attr('rel');
			if(sort_id>tr_sort_id) tr_sort_id = sort_id;
	    });	
		
		tr_sort_id += 1;
		
		re = new RegExp("sort_id", "g");     //正则
		str  = $('#default_tr1').html().replace(re, tr_sort_id);
		//console.log(str);
		var html = '<tr class="list_tr" rel="'+tr_sort_id+'">'+ str +'</tr>';
		if(list_count==0)
		  $('#list_data_tbody tr').before(html);	
		else
		  $('.list_tr:last').after(html);
		  
		hide_move();
		$('.select_type').each(function(){ select_type(this); });
		$('.select_type').change(function(){ select_type(this); });
	}
	//删除字段
	function remove_tr(_this){	
		$(_this).parent().parent().remove();
		hide_move();
	}

		//排序--向上
	function move_up(obj) { 
	  var objParentTR = $(obj).parent().parent(); 
	  var prevTR = objParentTR.prev(); 
	  if (prevTR.length > 0) { 
		prevTR.insertAfter(objParentTR); 
	  }
	  hide_move();
	} 
	//排序--向下
	function move_down(obj) { 
	  var objParentTR = $(obj).parent().parent(); 
	  var nextTR = objParentTR.next(); 
	  if (nextTR.length > 0) { 
		nextTR.insertBefore(objParentTR); 
	  } 
	  hide_move();
	} 
	//第一行只显示向下，最后一行只显示向上
	function hide_move(){
		$('.move_up').each(function() {
			$(this).show();
	    });
		$('.move_down').each(function() {
			$(this).show();
	    });	
		$('.list_tr:first').find('.move_up').hide();
		$('.list_tr:last').find('.move_down').hide();
	}

</script>

</body>
</html>
